package com.genntii.examManager.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.genntii.examManager.domain.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.ArrayList;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("select count(*) from user where mail = #{mail}")
    Integer mailExists(@Param("mail")String mail);

    @Select("select count(*) from user where username = #{username}")
    Integer usernameExists(@Param("username") String username);

    @Update("update user set password = #{password} where id = #{id}")
    void setPassword(@Param("password")String password, @Param("id")Long id);

    @Select("select * from user where mail = #{mail}")
    User selectUserByMail(@Param("mail")String mail);

    @Select("select * from user where username = #{username};")
    User selectUserByUser(@Param("username")String username);

    ArrayList<User> selectUserBatch(ArrayList<Long> userIds);

}
